package com.king.first.utils;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Date;

public class TestUtils {
    public static void main(String[] args) throws Exception {

        Double s = 183.0047641065639;

        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddhhmmss");
        Date parse = dateFormat.parse("20210616094500");
        System.out.println("20210616094500".substring(0, 8));
        String jsonString = "{\n" +
                "    \"data_time\": \"20210616094500\",\n" +
                "    \"meter\": \"1004\",\n" +
                "    \"data_value\": 183.0047641065639,\n" +
                "    \"funcid\": 10304,\n" +
                "    \"building\": \"5001061005\"\n" +
                "}";

        JSONObject jsonObject = JSON.parseObject(jsonString);
        jsonObject.put("dt", jsonObject.getString("data_time").substring(0, 8));
        EnergyHistory energyHistory = JSON.parseObject(jsonObject.toJSONString(), EnergyHistory.class);
        System.out.println(energyHistory);
    }
}